package com.frank.yinyuetai.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.frank.yinyuetai.Adapter.YueDanDetailRecycleViewAdapter;
import com.frank.yinyuetai.Bean.YueDanDetailBean;
import com.frank.yinyuetai.PlayVideoListener;
import com.frank.yinyuetai.R;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/8/19 0019.
 */
public class YueDanListFragment extends Fragment {
    @Bind(R.id.recyclerView)
    RecyclerView recyclerView;
    private YueDanDetailBean yueDanDetailBean;
    private YueDanDetailRecycleViewAdapter recycleViewAdapter;
    private PlayVideoListener playVideoListener;

    public void setPlayVideoListener(PlayVideoListener playVideoListener) {
        this.playVideoListener = playVideoListener;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.yuedan_list_recycleview, null);
        ButterKnife.bind(this, view);
        yueDanDetailBean = (YueDanDetailBean) getArguments().getSerializable("yueDanDetailBean");
        recycleViewAdapter = new YueDanDetailRecycleViewAdapter(yueDanDetailBean.getVideos(), this.getActivity(), playVideoListener);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        recyclerView.setAdapter(recycleViewAdapter);
        return view;
    }

    public static YueDanListFragment newInstance(YueDanDetailBean yueDanDetailBean) {
        YueDanListFragment fragment = new YueDanListFragment();
        Bundle bundle = new Bundle();
        bundle.putSerializable("yueDanDetailBean", yueDanDetailBean);
        fragment.setArguments(bundle);
        return fragment;
    }


}
